<!-- top navigation -->
<div class="top_nav">
    <div class="nav_menu">
        <nav class="" role="navigation">
            <div class="nav toggle">
                <a id="menu_toggle"><i class="fa fa-bars"></i></a>
            </div>

            <ul class="nav navbar-nav navbar-right">
                <li class="">
                    <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                        <img src="{{ URL::asset('images/users-female.png') }}" alt="">Admin
                        <span class=" fa fa-angle-down"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-usermenu pull-right">
                        <li><a id="user-info" href="javascript:;"> 个人信息</a></li>
                        <li><a id="user-updpwd" href="javascript:;"> 修改密码</a></li>
                        <li><a href="${base}/spring_security_cas_logout"><i class="fa fa-sign-out pull-right"></i> 退出</a></li>
                    </ul>
                </li>

            </ul>
        </nav>
    </div>
</div>


<script>
    $(function(){

        $('#user-info').click(function(){
            var data=JSON.parse('<sec:authentication property="principal" htmlEscape="false"/>');
            console.log('data:',data);
            DialogModal({
                closable:true,
                title:'个人信息',
                tplId:'emp-detail-tpl',
                data:data,
                showOkBtn:false
            });
        });

        $('#user-updpwd').click(function(){
            var data=JSON.parse('<sec:authentication property="principal" htmlEscape="false"/>');
            console.log('data:',data);
            DialogModal({
                closable:true,
                title:'修改密码',
                tplId:'emp-updpwd-tpl',
                data:{},
                callback:function(dialog){
                    var $form=$('#emp-updpwd-form');
                    var $error=$form.find('p.error');
                    $error.html('');
                    //var ispass = $.html5Validate.isAllpass($form);
                    // 全部验证通过
                    //if (ispass) {
                    var data=$form.serializeObject();
                    if(data.oldPassword==''||data.password==''||data.rePassword==''){
                        $error.html('请输入密码!');
                        return;
                    }
                    if(data.password!=data.rePassword){
                        $error.html('两次密码输入不一致!');
                        return;
                    }

                    $.post($base+'/employee/updatepwd',data,function(json){
                        if(json.result!=0){
                            AlertModal(json.message);
                        }else{
                            dialog.close();
                            AlertModal('修改密码成功,下次登录时生效!');
                        }
                    });
                    //}
                }
            });
        });


    });
</script>
<!-- /top navigation -->